﻿using CommunityToolkit.WinUI.UI.Controls;
using MetaDataParser.ViewModels;

using Microsoft.UI.Xaml.Controls;

namespace MetaDataParser.Views;

public sealed partial class MainPage : Page
{
    public MainViewModel ViewModel
    {
        get;
    }

    public MainPage()
    {
        ViewModel = App.GetService<MainViewModel>();
        InitializeComponent();
    }

    private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
    {
        ViewModel.SearchString = sender.Text;
        ViewModel.AdBindingInfo.Refresh();
    }

    private void DataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
    {
        if(e.Column is DataGridTextColumn textColumn)
        {
            textColumn.Binding.Mode = Microsoft.UI.Xaml.Data.BindingMode.OneWay;
        }
    }
}
